﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Aribaccio.Datum
{
    /// <summary>
    /// 数据库连接操作基本服务接口
    /// 基于EFCore.BulkExtensions大数据的处理
    /// </summary>
    public interface IDataServiceBulk : IDataServiceBase
    {
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <typeparam name="T">对象模型</typeparam>
        /// <param name="argItems">对象模型实体集合</param>
        /// <returns>返回处理结果</returns>
        Result InsertBulk<T>(List<T> argItems) where T : class;
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <typeparam name="T">对象模型</typeparam>
        /// <param name="argItems">对象模型实体集合</param>
        /// <returns>返回处理结果</returns>
        Task<Result> InsertBulkTask<T>(List<T> argItems) where T : class;

        /// <summary>
        /// 更新数据
        /// 说明：传入的实体如果不赋值,则更新为null,即传入的实体每个字段都要有值
        /// </summary>
        /// <typeparam name="T">对象模型</typeparam>
        /// <param name="argItems">对象模型实体集合</param>
        /// <returns>返回处理结果</returns>
        Result UpdateBulk<T>(List<T> argItems) where T : class;
        /// <summary>
        /// 更新数据[条件批量Lambda]
        /// 说明：要更新哪几个字段，就给传入的实体中的哪几个字段赋值
        /// </summary>
        /// <typeparam name="T">对象模型</typeparam>
        /// <param name="argWhereLambda">需要更新的条件</param>
        /// <param name="argModelItem">更新为的实体</param>
        Result UpdateBulk<T>(Expression<Func<T, bool>> argWhereLambda, T argModelItem) where T : class, new();
        /// <summary>
        /// 更新数据[条件批量Lambda]
        /// 说明：要更新哪几个字段，就给传入的实体中的哪几个字段赋值
        /// </summary>
        /// <param name="argWhereLambda">需要更新的条件</param>
        /// <param name="argModelItemLambda">更新为的实体</param>
        Result UpdateBulk<T>(Expression<Func<T, bool>> argWhereLambda, Expression<Func<T, T>> argModelItemLambda) where T : class, new();
        /// <summary>
        /// 更新数据
        /// 说明：传入的实体如果不赋值,则更新为null,即传入的实体每个字段都要有值
        /// </summary>
        /// <typeparam name="T">对象模型</typeparam>
        /// <param name="argItems">对象模型实体集合</param>
        /// <returns>返回处理结果</returns>
        Task<Result> UpdateBulkTask<T>(List<T> argItems) where T : class;
        /// <summary>
        /// 更新数据[条件批量Lambda]
        /// 说明：要更新哪几个字段，就给传入的实体中的哪几个字段赋值
        /// </summary>
        /// <typeparam name="T">对象模型</typeparam>
        /// <param name="argWhereLambda">需要更新的条件</param>
        /// <param name="argModelItem">更新为的实体</param>
        Task<Result> UpdateBulkTask<T>(Expression<Func<T, bool>> argWhereLambda, T argModelItem) where T : class, new();
        /// <summary>
        /// 更新数据[条件批量Lambda]
        /// 说明：要更新哪几个字段，就给传入的实体中的哪几个字段赋值
        /// </summary>
        /// <param name="argWhereLambda">需要更新的条件</param>
        /// <param name="argModelItemLambda">更新为的实体</param>
        Task<Result> UpdateBulkTask<T>(Expression<Func<T, bool>> argWhereLambda, Expression<Func<T, T>> argModelItemLambda) where T : class, new();

        /// <summary>
        /// 删除数据
        /// 说明：传入的list中的实体仅需要主键有值,它是根据主键删除的
        /// </summary>
        /// <typeparam name="T">对象模型</typeparam>
        /// <param name="argItems">对象模型实体集合</param>
        /// <returns>返回处理结果</returns>
        Result DeleteBulk<T>(List<T> argItems) where T : class;
        /// <summary>
        /// 删除数据
        /// 说明：传入的list中的实体仅需要主键有值,它是根据主键删除的
        /// </summary>
        /// <typeparam name="T">对象模型</typeparam>
        /// <param name="argItems">对象模型实体集合</param>
        /// <returns>返回处理结果</returns>
        Task<Result> DeleteBulkTask<T>(List<T> argItems) where T : class;
        /// <summary>
        /// 删除数据[条件批量Lambda]
        /// </summary>
        /// <typeparam name="T">对象模型</typeparam>
        /// <param name="argWhereLambda">需要删除的条件</param>
        /// <returns>返回处理结果</returns>
        Task<Result> DeleteBulkTask<T>(Expression<Func<T, bool>> argWhereLambda) where T : class;
    }
}
